VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "msadodc.ocx"
Begin VB.Form ValoresSugeridos 
   BackColor       =   &H00C8D0D4&
   Caption         =   "Valores Sugeridos"
   ClientHeight    =   3540
   ClientLeft      =   5640
   ClientTop       =   4065
   ClientWidth     =   8475
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   3540
   ScaleWidth      =   8475
   StartUpPosition =   2  'CenterScreen
   Begin VB.TextBox txtValoresSugeridos 
      BeginProperty Font 
         Name            =   "Arial Unicode MS"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Index           =   3
      Left            =   4920
      MaxLength       =   10
      TabIndex        =   3
      Top             =   1560
      Width           =   1095
   End
   Begin VB.TextBox txtValoresSugeridos 
      BeginProperty Font 
         Name            =   "Arial Unicode MS"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Index           =   2
      Left            =   1800
      MaxLength       =   10
      TabIndex        =   2
      Top             =   1560
      Width           =   1095
   End
   Begin VB.TextBox txtValoresSugeridos 
      BeginProperty Font 
         Name            =   "Arial Unicode MS"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Index           =   1
      Left            =   4920
      MaxLength       =   10
      TabIndex        =   1
      Top             =   1080
      Width           =   1095
   End
   Begin VB.TextBox txtValoresSugeridos 
      BeginProperty Font 
         Name            =   "Arial Unicode MS"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Index           =   0
      Left            =   1800
      MaxLength       =   10
      TabIndex        =   0
      Top             =   1080
      Width           =   1095
   End
   Begin VB.CommandButton cmdGuardar 
      BackColor       =   &H00C8D0D4&
      Caption         =   "&Guardar"
      BeginProperty Font 
         Name            =   "Arial Unicode MS"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   6600
      Picture         =   "ValoresSugeridos.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   1080
      Width           =   1215
   End
   Begin VB.CommandButton cmdSalir 
      BackColor       =   &H00C8D0D4&
      Caption         =   "&Salir"
      BeginProperty Font 
         Name            =   "Arial Unicode MS"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   7200
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   2760
      Width           =   1215
   End
   Begin MSAdodcLib.Adodc adoValoresSugeridos 
      Height          =   330
      Left            =   120
      Top             =   2880
      Visible         =   0   'False
      Width           =   2655
      _ExtentX        =   4683
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   1
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "AdoValoresSugeridos"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.Label lblError 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   255
      Left            =   4680
      TabIndex        =   10
      Top             =   2160
      Width           =   3135
   End
   Begin VB.Shape Shape2 
      BorderColor     =   &H000080FF&
      FillColor       =   &H00000080&
      FillStyle       =   0  'Solid
      Height          =   3945
      Left            =   8160
      Top             =   0
      Width           =   80
   End
   Begin VB.Shape Shape1 
      BorderColor     =   &H000080FF&
      FillColor       =   &H00000080&
      FillStyle       =   0  'Solid
      Height          =   80
      Left            =   120
      Top             =   2880
      Width           =   8415
   End
   Begin VB.Label Label4 
      BackStyle       =   0  'Transparent
      Caption         =   "Km. a Pagar:"
      BeginProperty Font 
         Name            =   "Arial Unicode MS"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000080&
      Height          =   255
      Left            =   120
      TabIndex        =   9
      Top             =   1560
      Width           =   1695
   End
   Begin VB.Label Label3 
      BackStyle       =   0  'Transparent
      Caption         =   "Km. a Cobrar:"
      BeginProperty Font 
         Name            =   "Arial Unicode MS"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000080&
      Height          =   255
      Left            =   3120
      TabIndex        =   8
      Top             =   1560
      Width           =   1695
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "Servicio a Pagar:"
      BeginProperty Font 
         Name            =   "Arial Unicode MS"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000080&
      Height          =   255
      Left            =   120
      TabIndex        =   7
      Top             =   1080
      Width           =   1695
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "Servicio a Cobrar:"
      BeginProperty Font 
         Name            =   "Arial Unicode MS"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000080&
      Height          =   255
      Left            =   3120
      TabIndex        =   6
      Top             =   1080
      Width           =   1695
   End
End
Attribute VB_Name = "ValoresSugeridos"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private hayError As Boolean

Private Sub Form_Load()
    'Inicializo los controles ado
    With adoValoresSugeridos
        .ConnectionString = CONEXBD
        .RecordSource = "SELECT * FROM ValoresSugeridos"
        .Refresh
        
        With .Recordset
            .MoveFirst
            txtValoresSugeridos(0) = .Fields!apagar
            txtValoresSugeridos(1) = .Fields!acobrar
            txtValoresSugeridos(2) = .Fields!Kmapagar
            txtValoresSugeridos(3) = .Fields!KmaCobrar
        End With
    End With
End Sub

Private Sub cmdGuardar_Click()
    hayError = False
    lblError.ForeColor = &HFF& 'Rojo
    lblError.Caption = ""
    
    'Validacion de campos:
    For I = 0 To 3
        '-No pueden estar vacios
        If txtValoresSugeridos(I) = "" Then
            lblError.Caption = "No puede dejar campos vacios"
            txtValoresSugeridos(I).SetFocus
            hayError = True
            I = 3 'Termino el bucle en el primer error que encuentre
        '-No pueden tener una coma sin valores ","
        ElseIf txtValoresSugeridos(I) = "," Then
            lblError.Caption = "No puede dejar la coma sola"
            txtValoresSugeridos(I).SetFocus
            hayError = True
            I = 3 'Termino el bucle en el primer error que encuentre
        End If
    Next I
    
    If hayError = False Then
        'No hay error, entonces procede a guardar los datos
    
        With adoValoresSugeridos.Recordset
            .Fields!apagar = CDbl(txtValoresSugeridos(0).Text)
            .Fields!acobrar = CDbl(txtValoresSugeridos(1).Text)
            .Fields!Kmapagar = CDbl(txtValoresSugeridos(2).Text)
            .Fields!KmaCobrar = CDbl(txtValoresSugeridos(3).Text)
            .Update
        End With
    
        'MensajeGuardado
        lblError.ForeColor = &HFF0000 'Azul
        lblError.Caption = "Datos guardados satisfactoriamente"
    End If
End Sub

Private Sub txtValoresSugeridos_KeyPress(Index As Integer, KeyAscii As Integer)
    lblError.Caption = ""
    If KeyAscii = 13 Then
        Select Case Index
            Case 0
                txtValoresSugeridos(1).SetFocus
            Case 1
                txtValoresSugeridos(2).SetFocus
            Case 2
                txtValoresSugeridos(3).SetFocus
            Case 3
                cmdGuardar.SetFocus
        End Select
    End If
    KeyAscii = ValidarImporte(KeyAscii, txtValoresSugeridos(Index))
End Sub

Private Sub txtValoresSugeridos_GotFocus(Index As Integer)
    SelTex txtValoresSugeridos(Index)
End Sub

Private Sub cmdSalir_Click()
    Unload Me
End Sub
